<?php
/*
 * Gallery - a web based photo album viewer and editor
 * Copyright (C) 2000-2002 Bharat Mediratta
 * 
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or (at
 * your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 */

// Hack prevention.
if (!empty($_REQUEST["GALLERY_BASEDIR"])) {
	print "Security violation\n";
	exit;
}
require_once("./init.php"); 
 
// Hack check
if (!$gallery->user->canWriteToAlbum($gallery->album)) {
	exit;
}
$all = !strcmp($index, "all");
?>

<html>
<head>
<title><?php echo _XG_RESIZES;?><?php echo $all ? _XG_MULTIPLE : _XG_SINGLES ?></title>
<?php echo getStyleSheetLink() ?>
</head>
<body>
<?php
if ($gallery->session->albumName && isset($index)) {
	if (isset($resize)) {
		if (!strcmp($index, "all")) {
			$np = $gallery->album->numPhotos(1);
			echo "<br />".sprintf(_XG_RESIZING_NP_PHOTOS,"$np");
			my_flush();
			for ($i = 1; $i <= $np; $i++) {
				echo "<br />".sprintf(_XG_PROCESSING_IMAGE,"$i");
				my_flush();
				set_time_limit($gallery->app->timeLimit);
				$gallery->album->resizePhoto($i, $resize);
			}
		} else {
			echo "<br />"._XG_RESIZING_ONE_PHOTS;
			my_flush();
			set_time_limit($gallery->app->timeLimit);
			$gallery->album->resizePhoto($index, $resize);
		}
		$gallery->album->save();
		dismissAndReload();
		return;
	} else {
?>
<center><font size="+1"><?php echo _XG_RESIZES;?><?php echo $all ? _XG_MULTIPLE : _XG_SINGLES ?>:</font></center><br /><br />
<?php echo _XG_SELECTED_SIZE_PHOTO;?>
<br />
<br />
<br />
<center>
<?php echo _XG_WHATISTHETARGET; ?> <?php echo $all ? _XG_ALL_PHOTOS_IN_ALBUM : _XG_THIS_PHOTO; ?> ?
<br />
<br />
<?php echo makeFormIntro("resize_photo.php"); ?>
<input type="hidden" name="index" value=<?php echo $index?>>
<input type="submit" name="resize" value="<?php echo _XG_ORIGINAL_SIZE;?>">
<input type="submit" name="resize" value="1024">
<input type="submit" name="resize" value="800">
<input type="submit" name="resize" value="700">
<input type="submit" name="resize" value="640">
<input type="submit" name="resize" value="600">
<input type="submit" name="resize" value="500">
<input type="submit" name="resize" value="400">
<br />
<br />
<br />
<input type="submit" value="<?php echo _XG_CANCEL;?>" onclick='parent.close()'>
</form>
<br/>
</center>
<?php
if (!$all) {
	echo $gallery->album->getThumbnailTag($index);
	} 
	}
	} else {
	gallery_error(_XG_ERROR_NO_ALBUM_SELECT);
}
?>
</body>
</html>